#ifndef SEU_BENCODE_H
#define SEU_BENCODE_H
#include"include.h"

typedef enum {
   BE_STR,
   BE_INT,
   BE_LIST,
   BE_DICT
} be_dat_type;

typedef struct {
   be_dat_type type;
   union {
      mystr *s;
      long long i;
      list_t *l;
      dict_t *d;
   } dat;
} be_dat;

//Returns a list of elements.
//If it fails returns -index of what it failed on
list_t *bdecode(char *dat, long datlen);
dict_t *bdecodeDict(char *dat, long datlen);
be_dat *bdecodeelement(char *dat, int *ndx, long datlen);
int bestrcmp(be_dat *l, be_dat *r);
void printBeDat(be_dat *d);

void beFreeDat(be_dat *dat);

void beFreeDict(dict_t *be_dict);
void beFree(list_t *bencoded_data);

#endif
